<section class="content" id="save-form">
    <form class="form-horizontal" role="form" data-action="{$save_url}" data-option-demo="{if $id}{:url('menu/save', ['id' => $id])}{else /} {:url('menu/save')}{/if}">
        <div class="form-group">
            <label for="name" class="col-md-2 control-label">名称</label>
            <div class="col-md-6">
                <input type="text" name="name" class="form-control" value="{$name|default=''}" required id="name" placeholder="菜单名称">
            </div>
        </div>
        <div class="form-group">
            <label for="route" class="col-md-2 control-label">路由</label>
            <div class="col-md-6">
                <input type="text" class="form-control" id="route" name="route" value="{$route|default=''}" required placeholder="路由">
            </div>
        </div>

        <div class="form-group">
            <label for="name" class="col-md-2 control-label">父菜单</label>
            <div class="col-md-6">
                <select class="form-control" id="parent_id" name="parent_id">
                    <option value="0" {if $parent_id == 0}selected{/if}>顶级菜单</option>
                    {foreach $menus as $k => $v}
                    <option value="{$k}" {if $k == $parent_id}selected{/if} >{$v}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="route" class="col-md-2 control-label">数据</label>
            <div class="col-md-6">
                <textarea class="form-control" name="data" rows="3" placeholder="json格式，如{&quot;icon&quot;:&quot;fa-cog&quot;}">{$data|default=''}</textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-6">
                <button type="submit" class="btn btn-default submit-btn">提交</button>
            </div>
        </div>
    </form>
</section>

<script>
    var validateConfig = {
        rules: {
            name: "required",
            route: "required",
            parent_id: "required"
        },
        // messages: {
        //     firstname: "请输入您的名字",
        //     lastname: "请输入您的姓氏",
        //     username: {
        //         required: "请输入用户名",
        //         minlength: "用户名必需由两个字符组成"
        //     },
        //     password: {
        //         required: "请输入密码",
        //         minlength: "密码长度不能小于 5 个字符"
        //     },
        //     confirm_password: {
        //         required: "请输入密码",
        //         minlength: "密码长度不能小于 5 个字符",
        //         equalTo: "两次密码输入不一致"
        //     },
        //     email: "请输入一个正确的邮箱",
        //     agree: "请接受我们的声明",
        //     topic: "请选择两个主题"
        // }
    };
</script>